﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminMaster.Master" AutoEventWireup="true"
    CodeBehind="camiones.aspx.cs" Inherits="TrangestAdmin.Camiones" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <article class="module width_full">
        <header>
            <h3 class="tabs_involved">
                Camiones
            </h3>
        </header>
        <div class="tab_container">
            <fieldset>
                <legend>Tabla Camiones</legend>
                <table>
                    <tr>
                        <td>
                            Filtrar Chapa:
                        </td>
                        <td>
                            <asp:TextBox ID="uxFiltro" runat="server" Text="" AutoPostBack="true" OnTextChanged="uxFiltro_TextChanged"></asp:TextBox>
                        </td>
                        <td>
                            Filtrar Marca:
                        </td>
                        <td>
                            <asp:TextBox ID="uxFiltroMarca" runat="server" Text="" AutoPostBack="true" OnTextChanged="uxFiltroMarca_TextChanged"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <table>
                    <tr>
                        <td>
                            <asp:GridView ID="uxTablaCamiones" runat="server" AutoGenerateColumns="False" DataKeyNames="id_camion"
                                DataSourceID="sqlCamiones" CssClass="tablesorter" AllowPaging="True" AllowSorting="True"
                                PageSize="12" onrowcancelingedit="uxTablaCamiones_RowCancelingEdit" 
                                onrowediting="uxTablaCamiones_RowEditing" 
                                onrowupdating="uxTablaCamiones_RowUpdating" 
                                onrowdatabound="uxTablaCamiones_RowDataBound" 
                                onrowdeleting="uxTablaCamiones_RowDeleting">
                                <AlternatingRowStyle CssClass="tablesorter_alt" />
                                <Columns>
                                    <asp:CommandField ShowEditButton="True" UpdateImageUrl="images/icn_alert_success.png"
                                        EditImageUrl="images/icn_edit.png" DeleteImageUrl="images/icn_trash.png" ButtonType="Image"
                                        CancelImageUrl="images/icn_alert_error.png" />
                                    <asp:BoundField DataField="id_camion" HeaderText="id_camion" InsertVisible="False"
                                        ReadOnly="True" SortExpression="id_camion" Visible="false"/>
                                    <asp:BoundField DataField="nro_chapa" HeaderText="nro_chapa" SortExpression="nro_chapa" ControlStyle-Width="70px" />
                                    <asp:BoundField DataField="marca" HeaderText="marca" SortExpression="marca" ControlStyle-Width="250px"/>
                                    <asp:BoundField DataField="modelo" HeaderText="modelo" SortExpression="modelo" ControlStyle-Width="100px" />
                                    <asp:BoundField DataField="color" HeaderText="color" SortExpression="color" ControlStyle-Width="100px" />
                                    <asp:BoundField DataField="chapa_carreta" HeaderText="chapa_carreta" SortExpression="chapa_carreta" ControlStyle-Width="80px" />
                                    <asp:BoundField DataField="combustible_x100" HeaderText="combustible_x100" SortExpression="combustible_x100" ControlStyle-Width="70px" />
                                    <asp:BoundField DataField="nro_chasis" HeaderText="nro_chasis" SortExpression="nro_chasis" ControlStyle-Width="150px" />
                                    <asp:BoundField DataField="anho" HeaderText="anho" SortExpression="anho" ControlStyle-Width="40px" />
                                    <asp:BoundField DataField="peso" HeaderText="peso" SortExpression="peso" ControlStyle-Width="70px" />
                                    <asp:TemplateField>                                        
                                        <ItemTemplate>
                                            <asp:ImageButton ID="btnDelete" AlternateText="Delete" ImageUrl="~/images/icn_trash.png" runat="server" OnClientClick="return confirm('Está seguro de eliminar esta fila?');" CommandName="Delete" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <HeaderStyle CssClass="tableHeader" />
                            </asp:GridView>
                        </td>
                    </tr>
                </table>
            </fieldset>
            <fieldset>
                <legend>Nuevo Camión</legend>
                <table>
                    <tr>
                        <td style="text-align: right;">
                            Nro.Chapa:
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewNroChapa" runat="server" Text=""></asp:TextBox>
                        </td>
                        <td style="text-align: right;">
                            Marca:
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewMarca" runat="server"></asp:TextBox>
                        </td>
                        <td style="text-align: right;">
                            Color:
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewColor" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right;">
                            Chapa Carreta:
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewChapaCarreta" runat="server"></asp:TextBox>
                        </td>
                        <td style="text-align: right;">
                            Combustible x 100:
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewComb100" runat="server"></asp:TextBox>
                        </td>
                        <td style="text-align: right;">
                            Nro.Chasis:
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewNroChasis" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right;">
                            Anho:
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewAnho" runat="server"></asp:TextBox>
                        </td>
                        <td style="text-align: right;">
                            Peso:
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewPeso" runat="server"></asp:TextBox>
                        </td>
                        <td style="text-align: right;">Modelo
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewModelo" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                            <asp:Button ID="uxInsertNew" runat="server" Text="Insertar" 
                                onclick="uxInsertNew_Click" />
                        </td>
                    </tr>
                </table>
            </fieldset>
        </div>
    </article>
    <asp:SqlDataSource ID="sqlCamiones" runat="server" ConnectionString="<%$ ConnectionStrings:trangestConnectionString %>"
        ProviderName="<%$ ConnectionStrings:trangestConnectionString.ProviderName %>"
        SelectCommand="SELECT * FROM camiones ORDER BY id_camion;" 
        UpdateCommand="UPDATE    camiones
SET              nro_chapa = :nro_chapa, marca = :marca, modelo = :modelo, color = :color, chapa_carreta = :chapa_carreta, us_utlmod = :us_utlmod, 
                      fecha_ultmod = now(), combustible_x100 = :combustible_x100, nro_chasis = :nro_chasis, anho = :anho, peso = :peso
WHERE     id_camion = :id_camion;"
        DeleteCommand="DELETE FROM camiones WHERE id_camion = :id_camion;"
        InsertCommand="INSERT INTO camiones (nro_chapa, marca, modelo, color, chapa_carreta, us_creacion, fecha_creacion, combustible_x100, nro_chasis, anho, peso) 
        VALUES ( (@nro_chapa), (@marca), (@modelo), (@color), (@chapa_carreta), (@us_creacion), Now(), (@combustible_x100), (@nro_chasis), (@anho), (@peso) );">
    <UpdateParameters>
        <asp:Parameter Name="nro_chapa" DbType="String" />
        <asp:Parameter Name="marca" DbType="String" />
        <asp:Parameter Name="modelo" DbType="String" />
        <asp:Parameter Name="color" DbType="String" />
        <asp:Parameter Name="chapa_carreta" DbType="String" />
        <asp:SessionParameter Name="us_utlmod" DbType="String" SessionField="username" />
        <asp:Parameter Name="combustible_x100" DbType="Int32" />
        <asp:Parameter Name="nro_chasis" DbType="String" />
        <asp:Parameter Name="anho" DbType="Int32" />
        <asp:Parameter Name="peso" DbType="Int32" />
    </UpdateParameters>
    <InsertParameters>
        <asp:ControlParameter Name="nro_chapa" DbType="String" ControlID="uxNewNroChapa" PropertyName="Text" DefaultValue="AAA000" />
        <asp:ControlParameter Name="marca" DbType="String" ControlID="uxNewMarca" PropertyName="Text" DefaultValue="" />
        <asp:ControlParameter Name="modelo" DbType="String" ControlID="uxNewModelo" PropertyName="Text" DefaultValue="" />
        <asp:ControlParameter Name="color" DbType="String" ControlID="uxNewColor" PropertyName="Text" DefaultValue="" />
        <asp:ControlParameter Name="chapa_carreta" DbType="String" ControlID="uxNewChapaCarreta" PropertyName="Text" DefaultValue="" />
        <asp:ControlParameter Name="combustible_x100" DbType="Int32" ControlID="uxNewComb100" PropertyName="Text" DefaultValue="0" />
        <asp:ControlParameter Name="nro_chasis" DbType="String" ControlID="uxNewNroChasis" PropertyName="Text" DefaultValue="" />
        <asp:ControlParameter Name="anho" DbType="Int32" ControlID="uxNewAnho" PropertyName="Text" DefaultValue="0" />
        <asp:ControlParameter Name="peso" DbType="Int32" ControlID="uxNewPeso" PropertyName="Text" DefaultValue="0" />
        <asp:SessionParameter Name="us_creacion" DbType="String" SessionField="username" />
    </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>
